const path = require('path')
const fs = require('fs')
module.exports = {
  mode: 'universal',
  telemetry: false,
  /*
  ** Headers of the page
  */
  head: {
    // title: process.env.npm_package_name || '',
    title: '机房信息管理系统',
    meta: [
      {charset: 'utf-8'},
      {name: 'viewport', content: 'width=device-width, initial-scale=1'},
      {hid: 'description', name: 'description', content: process.env.npm_package_description || ''}
    ],
    link: [
      {rel: 'icon', type: 'image/x-icon', href: '/favicon.ico'}
    ]
  },
  router: {
    middleware: 'metaTitle',
    //扩展路由
    extendRoutes(routes, resolve) {
      // for(item in routes){
      //   if(routes[item].name === 'index'){routes[item].title = "主页"};
      //   if(routes[item].name === 'device'){routes[item].title = "设备资料"};
      //   if(routes[item].name === 'iptable'){routes[item].title = "IP地址表"};
      //   if(routes[item].name === 'tops'){routes[item].title = "拓扑图"};
      //   if(routes[item].name === 'index'){routes[item].title = "主页"};
      // }
      // // routes.push({
      // // name:'index',path:'/', meta: {
      // //       requireAuth: false, //菜单权限
      // //       title: '欢迎页', //菜单名
      // //   },
      // // })
      //  console.log(routes);
    },
  },
  /*
  ** Customize the progress-bar color
  */
  // loading: {color: '#fff'},
  loading: '~/components/loading.vue',
  /*
  ** Global CSS
  */
  css: [
    'element-ui/lib/theme-chalk/index.css',

    // '@assets/styles/global.less',
  ],
  /*
  ** Plugins to load before mounting the App
  */
  plugins: [
    '@/plugins/element-ui',
    '@/plugins/umy-ui',
    '@/plugins/router',
    {
      src: '~/plugins/axios',
      ssr: true,//服务端渲染
    },
  ],
  /*
  ** Nuxt.js dev-modules
  */
  buildModules: [],
  /*
  ** Nuxt.js modules
  */
  modules: [
    // Doc: https://axios.nuxtjs.org/usage
    '@nuxtjs/axios',
    'cookie-universal-nuxt',
    '@nuxtjs/proxy'
    // '@nuxtjs/style-resources'
  ],
  // styleResources: {
  //   less: '@/assets/vars.less'
  // },
  /*
  ** Axios module configuration
  ** See https://axios.nuxtjs.org/options
  */
  axios: {
    proxy: true,//开启axios跨域
    // prefix:'/fb'
  },
  proxy: {
//     '/files': {
//
//       target: 'http://127.0.0.1:8080', // 目标接口域名
//
// // target: 'http://192.168.0.168:9001', // 本地
//
//       changeOrigin: true, // 表示是否跨域
//
//       pathRewrite: {
//         '^/files': '/', // 把 /api 替换成 /
//       }
//     },
//     '/fb': {
//       target: 'http://127.0.0.1:8080/fb/', // 目标接口域名
//       changeOrigin: true, // 表示是否跨域
//
//       pathRewrite: {
//         '^/fb': '/', // 把 /fb 替换成 /
//       }
  //  },

  // '/api': {
  //   target: 'http://localhost:3000',//api接口地址
  //   changeOrigin: true,
  //   pathRewrite: {
  //     //'^/api':''
  //   }
  // },
  // '/files/*': {
  //   target: 'http://127.0.0.1:8080',
  //    changeOrigin: true,
  // }
},
  /*
  ** Build configuration
  */
  build: {
  transpile: [/^element-ui/],
   babel:{
    "plugins": [
    [
      "component",
      {
        "libraryName": "umy-ui",
        "styleLibraryName": "theme-chalk"
      }
    ]
  ]
   },
    /*
    ** You can extend webpack config here
    */
    extend(config, ctx)
  {
  }
}
,

server: {
  https: {
    key: fs.readFileSync(path.resolve(__dirname, 'cert.key')),
      cert
  :
    fs.readFileSync(path.resolve(__dirname, 'cert.crt'))
  }
}

}
